using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

namespace Gameplay.PVE
{
    public class GgameSceneConfig: ScriptableObject
    {
        public List<string> PrefabPaths;

        public List<PrefabData> PrefabDatas;
        
        public SceneRenderData RenderData = new SceneRenderData();


        public string GetPrefabResPath(PrefabData prefabData)
        {
            if (prefabData.resPathIndex > PrefabPaths.Count - 1)
            {
                return "";
            }
            return PrefabPaths[prefabData.resPathIndex];
        }
    }


    [System.Serializable]
    public class PrefabData
    {
        public int resPathIndex;

        public Vector3 position;

        public Vector3 rotation;

        public Vector3 scale;

        public bool isStatic;

        public List<MeshRendererData> MeshRendererDatas = new List<MeshRendererData>();
        
        public List<string> additionalInfo;
        
        [NonSerialized]
        public string resPath;
    }

    [System.Serializable]
    public class MeshRendererData
    {
        public int renderIndex;
        
        public int lightmapIndex;
        
        public Vector4 lightmapScaleOffset;

        public float scaleInLightmap;
    }


    [System.Serializable]
    public class SceneRenderData
    {
        /// <summary>
        /// 是否分块烘焙，是的话Lightmap会很多，需要动态管理；否的话就全部加载
        /// </summary>
        public bool useBlockBake;
        
        // lightMap
        public List<string> lightMapColorPath;

        public List<string> lightMapDirPath;
        
        // fog
        public bool isFog;
        public Color fogColor;
        public float fogStart;
        public float fogEnd;
        public FogMode fogMode;
        
        // skyBox
        public string skyBoxMaterialPath;
        
        // 反射探针
        public string reflectionProbePath;
        
        // other
        public Color ambientColor;
        public DefaultReflectionMode reflectionMode;
        public AmbientMode ambientMode;

        // shadow cache
        // 实现文档: https://youzu.feishu.cn/wiki/wikcnPIUX0IKMoQImmaFaaA3gqd

        /// <summary>
        /// Shadow Cache 深度图
        /// </summary>
        public string shadowCacheDepthTexturePath;

        /// <summary>
        /// Shadow Cache 摄像机的矩阵
        /// </summary>
        public Matrix4x4 shadowCacheMatrix;

        /// <summary>
        /// Shadow Cache 纹素大小
        /// </summary>
        public float shadowCacheTexelSize;
    }

}
